package com.umfwechat.h5.controller.fund;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.umfwechat.common.ReqMessage;
import com.umfwechat.common.code.RetCode;
import com.umfwechat.common.constant.CacheConsts;
import com.umfwechat.common.constant.CommonConsts;
import com.umfwechat.common.constant.MsgConsts;
import com.umfwechat.common.constant.PropertyConsts;
import com.umfwechat.common.constant.ValueConsts;
import com.umfwechat.util.DateTimesUtil;
import com.umfwechat.util.FormatUtil;
import com.umfwechat.util.HttpUtil;
import com.umfwechat.util.OrderIdUtil;
import com.umfwechat.util.RedisUtil;
import com.umfwechat.util.ReqMessageUtil;
import com.umfwechat.util.ResultJsonUtil;
import com.umfwechat.util.SmsCheckUtil;
import com.umfwechat.util.SortUtil;
import com.umfwechat.util.StringUtil;
import com.umpay.operation.common.ResMessage;
import com.umpay.operation.model.edrawInf.EdrawInf;
import com.umpay.operation.model.fundPurchase.FundMerInfo;
import com.umpay.operation.service.edrawInf.remote.EdrawInfServiceRemote;
import com.umpay.operation.service.fundPurchase.FundServiceRemote;
import com.umpay.sp.model.saas.StoreInf;
import com.umpay.sp.service.saas.remote.StoreInfServiceRemote;
import com.umpay.sp.util.AmountUtil;
import com.umpay.sp.xml.XmlData;

/**
 * @ClassName OpenedAccountController
 * @desc 已开户
 * * 1.获取固定基金编号和基金名称
 * * 2.已开户用户主页初期化
 * * 3.总资产显示隐藏
 * * 4.最近N个月份列表
 * * 5.订单查询
 * * 6.收益查询
 * * 7.转出初期化
 * * 8.转出

 * @author liuchunyan
 * @date 2017-09-18
 * @version 1.0
 * 
 */
@Controller
@RequestMapping("/h5/fund/opendAccount")
public class OpenedAccountController {
	private static Logger logger = LoggerFactory.getLogger(OpenedAccountController.class); 

	//商户绑定银行卡信息
	@Resource
	private EdrawInfServiceRemote edrawInfServiceRemote;
	 
	//基金申购预约商户接口
	@Resource
	private FundServiceRemote fundServiceRemote;
	
	//店铺部署详情列表接口
	@Resource
	private StoreInfServiceRemote storeInfServiceRemote;
	
	/**
	 * 获取固定基金编号和基金名称
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/getFundList",produces="text/html;charset=UTF-8")
	@ResponseBody
	public String getFundList(HttpServletRequest request, HttpServletResponse response){
		Map<String, Object> resultMap = new HashMap<String, Object>();
		resultMap.put(CommonConsts.RETCODE, RetCode.SUCCESS);
		resultMap.put(CommonConsts.RETMSG, "获取固定基金编号和基金名称成功");
		//基金列表
		Map<String, String> dataMap = new HashMap<String, String>();
		dataMap.put(PropertyConsts.FUNDNO, PropertyConsts.FUNDNAME);
		
		resultMap.put(CommonConsts.RESULTLIST, dataMap);
		logger.info("获取固定基金编号和基金名称成功 resultMap = " + resultMap);
		return JSONObject.fromObject(resultMap).toString();
	} 
	
	/**
	 * 已开户用户主页初期化
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/initOpendAccount",produces="text/html;charset=UTF-8")
	@ResponseBody
	public String initOpendAccount(HttpServletRequest request, HttpServletResponse response){
		logger.info("【已开户用户主页初期化】开始");
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try{
			//获取登录人的商户编号
			String merId = "";
			if(request.getSession().getAttribute(CommonConsts.MERID) != null){
				merId = request.getSession().getAttribute(CommonConsts.MERID).toString();
			}
			
			if(StringUtil.isEmpty(merId)){
				logger.info("获取登录人的商户编号失败");
				resultMap.put(CommonConsts.RETCODE, RetCode.FAIL);
				resultMap.put(CommonConsts.RETMSG, "已开户用户主页初期化失败");
				return JSONObject.fromObject(resultMap).toString();
			}
			
			//基金累积收益（业务线）
			Map<String, Object> paramMap = new HashMap<String, Object>();
			ReqMessage reqMessage = ReqMessageUtil.makeFundReq();
			//流水号
			paramMap.put(CommonConsts.RPID, reqMessage.getRpid());
			//日期
			paramMap.put(CommonConsts.REQDATE, reqMessage.getReqDate());
			//时间
			paramMap.put(CommonConsts.REQTIME, reqMessage.getReqTime());
			//版本号
			paramMap.put(CommonConsts.VERSION, "1.0");
			//商户编号
			paramMap.put(CommonConsts.MERID, PropertyConsts.FUNDMERID);
			//用户所属的商户号
			paramMap.put(CommonConsts.USERMERID, merId);
			//用户编号
			paramMap.put(CommonConsts.USERID, merId);
			//基金编号
			paramMap.put(CommonConsts.FUNDNO, PropertyConsts.FUNDNO);
			//基金业务产品号
			paramMap.put(CommonConsts.BPRODUCTID, PropertyConsts.BPRODUCTID);
			logger.info("【基金累积收益（业务线）】访问路径："+ PropertyConsts.ESOOPAY_J06001 + " 输入参数：" + paramMap);	
			Map<String, Object> balanceMap = HttpUtil.httpPostForm2Xml(PropertyConsts.ESOOPAY_J06001, paramMap);
			logger.info("【基金累积收益（业务线）】输出参数：" + balanceMap);
			if(!balanceMap.get(CommonConsts.RETCODE).equals(RetCode.SUCCESS)){
				logger.info("【基金累积收益（业务线）】查询失败");
				resultMap.put(CommonConsts.RETCODE, RetCode.FAIL);
				resultMap.put(CommonConsts.RETMSG, "已开户用户主页初期化失败");
				return JSONObject.fromObject(resultMap).toString();
			}
			
			//七日年化收益率列表
			List<Map<String,String>> fundRateList = null;
			Calendar calendar = Calendar.getInstance();
			//今天日期
			String currentDate = DateTimesUtil.date8(calendar.getTime());
			//6天前日期
			String preSixDate = DateTimesUtil.addDays(currentDate, -6);
			//七日年化收益率折线图（业务线） 
			Map<String, Object> param7DMap = new HashMap<String, Object>();
			//流水号
			param7DMap.put(CommonConsts.RPID, ReqMessageUtil.makeFundReq().getRpid());
			//基金编号
			param7DMap.put(CommonConsts.FUNDNO, PropertyConsts.FUNDNO);
			//起始日期
			param7DMap.put(CommonConsts.START_DATE, preSixDate);
			//结束日期
			param7DMap.put(CommonConsts.END_DATE, currentDate);
			logger.info("【七日年化收益率折线图（业务线）】访问路径："+ PropertyConsts.FPBG_S01003 + " 输入参数：" + param7DMap);	
			Map<String, Object> annual7DMap = HttpUtil.httpPostForm2Xml(PropertyConsts.FPBG_S01003, param7DMap);
			logger.info("【七日年化收益率折线图（业务线）】输出参数：" + annual7DMap);
			if(!annual7DMap.get(CommonConsts.RETCODE).equals(RetCode.SUCCESS)){
				resultMap.put(CommonConsts.RETCODE, RetCode.FAIL);
				resultMap.put(CommonConsts.RETMSG, "七日年化收益率折线图（业务线）查询失败");
				return JSONObject.fromObject(resultMap).toString();
			}
			String fundRateListStr = (String) annual7DMap.get(CommonConsts.FUNDRATELIST);
			List<Map<String, String>> fundRateListNew = new Gson().fromJson(fundRateListStr, new TypeToken<List<Map<String, String>>>(){}.getType());
			
			if(fundRateListNew.size() > 0){
				//按日期排序
				fundRateListNew = SortUtil.sortListAsc(fundRateListNew, CommonConsts.OPPOSITEDATE);
				fundRateList = new ArrayList<Map<String,String>>();
				for(Map<String,String> fundRateMap : fundRateListNew){
					Map<String,String> dataMap = new HashMap<String,String>();
					//对应时间(yyyy-MM-dd)
					dataMap.put(CommonConsts.OPPOSITEDATE, DateTimesUtil.date10(fundRateMap.get(CommonConsts.OPPOSITEDATE).toString()));
					//七日年化（货币基金才有）
					dataMap.put(CommonConsts.ANNUAL7D, FormatUtil.setScale4(fundRateMap.get(CommonConsts.ANNUAL7D)).toString());
					//万分收益
					dataMap.put(CommonConsts.UNITACCRUA, FormatUtil.setScale4(fundRateMap.get(CommonConsts.UNITACCRUA)).toString());
					fundRateList.add(dataMap);
				}
			}
			//是否上升 （0：非上升；1：上升）
			String isUp = "0";
			//今日万分收益
			String unitAccrua = "0.00";
			//今日七日年化率
			String annual7D = "0.00";
			//昨日七日年化率
			String yestodayAnnual7D = "0.00";
			//最小七日年化率
			String minAnnual7D = "0";
			//最大七日年化率
			String maxAnnual7D = "0";
			if(fundRateList != null && fundRateList.size() > 0){
				for(int i=0;i<fundRateList.size();i++){
					String oppositeDate = fundRateList.get(i).get(CommonConsts.OPPOSITEDATE).replaceAll("-", "");
					String yestoday = DateTimesUtil.addDays(currentDate, -1);
					if(currentDate.equals(oppositeDate)){
						//今日七日年化率
						annual7D = fundRateList.get(fundRateList.size()-1).get(CommonConsts.ANNUAL7D);
						//今日万分收益
						unitAccrua = fundRateList.get(fundRateList.size()-1).get(CommonConsts.UNITACCRUA);
					}else if(yestoday.equals(oppositeDate)){
						//昨日七日年化率
						yestodayAnnual7D = fundRateList.get(fundRateList.size()-2).get(CommonConsts.ANNUAL7D);
					}
				}
				//今日七日年化率>=昨日七日年化率时，上升
				if(annual7D.compareTo(yestodayAnnual7D) >= 0){
					isUp = "1";
				}
				
				//获取最小七日年化率、最大七日年化率
				for(int i=0; i<fundRateList.size(); i++){
					String annual7DStr = fundRateList.get(i).get(CommonConsts.ANNUAL7D);
					if(i==0){
						minAnnual7D = annual7DStr;
						maxAnnual7D = annual7DStr;
					}
					if(annual7DStr.compareTo(minAnnual7D) < 0){
						minAnnual7D = annual7DStr;
					}
					if(annual7DStr.compareTo(maxAnnual7D) > 0){
						maxAnnual7D = annual7DStr;
					}
				}
			}
			
			com.umpay.operation.common.ReqMessage reqMess = ReqMessageUtil.makeOpReq();
			//基金编号
			reqMess.put(CommonConsts.FUNDNO, PropertyConsts.FUNDNO);
			//商户编号
			reqMess.put(CommonConsts.MERID, merId);
			logger.info("【基金申购预约商户查询接口】入参" + reqMess);
			ResMessage resMess = fundServiceRemote.queryFundMerInfo(reqMess);
			logger.info("【基金申购预约商户查询接口】出参" + resMess);
			if(!resMess.getRetCode().equals(RetCode.SUCCESS)){
				logger.info("查询基金申购预约商户失败");
				return ResultJsonUtil.resultJson(RetCode.FAIL, MsgConsts.E00433016);
			}
			FundMerInfo fundmerInfo = (FundMerInfo)resMess.getValue("fundmerInfo");
			
			//缓存中获取总资产显示状态
			String amtDisStatusKey = CacheConsts.AMTDISSTATUS.replace(CommonConsts.MERID, merId);
			String amtDisStatus = RedisUtil.get(amtDisStatusKey);
			if(StringUtil.isEmpty(amtDisStatus)){
				RedisUtil.set(amtDisStatusKey, PropertyConsts.THREEMONTH, "1");
				amtDisStatus = RedisUtil.get(amtDisStatusKey);
			}
			
			resultMap.put(CommonConsts.RETCODE, RetCode.SUCCESS);
			resultMap.put(CommonConsts.RETMSG, "已开户用户主页初期化成功");
			//昨日收益(分转元)
			String lastDayProfit = "0.00";
			if(balanceMap.get(CommonConsts.LASTDAYPROFIT) != null){
				lastDayProfit = AmountUtil.Cent2Dollar(balanceMap.get(CommonConsts.LASTDAYPROFIT).toString());
			}
			resultMap.put(CommonConsts.LASTDAYPROFIT, lastDayProfit);
			//总资产(分转元)
			String totalVol = "0.00";
			if(balanceMap.get(CommonConsts.TOTALVOL) != null){
				totalVol = AmountUtil.Cent2Dollar(balanceMap.get(CommonConsts.TOTALVOL).toString());
			}
			resultMap.put(CommonConsts.TOTALVOL, totalVol);
			//累计收益(分转元)
			String totalIncome = "0.00";
			if(balanceMap.get(CommonConsts.TOTALINCOME) != null){
				totalIncome = AmountUtil.Cent2Dollar(balanceMap.get(CommonConsts.TOTALINCOME).toString());
			}
			resultMap.put(CommonConsts.TOTALINCOME, totalIncome);
			//万分收益
			resultMap.put(CommonConsts.UNITACCRUA, unitAccrua);
			//七日年化收益率
			resultMap.put(CommonConsts.ANNUAL7D, annual7D);
			//最近7日的七日年化率列表
			resultMap.put(CommonConsts.ANNUAL7DLIST, fundRateList);
			//是否上升(0:下降  1:上升)
			resultMap.put(CommonConsts.ISUP, isUp);
			//结算款自动转入状态(0:关闭   1:打开)
			resultMap.put(CommonConsts.AUTOROLLINSTATUS, fundmerInfo == null ? "0" : fundmerInfo.getState());
			//总资产显示状态(0:不显示1:显示)
			resultMap.put(CommonConsts.AMTDISSTATUS, amtDisStatus);
			//最小七日年化率
			resultMap.put(CommonConsts.MIN_ANNUAL7D, minAnnual7D);
			//最大七日年化率
			resultMap.put(CommonConsts.MAX_ANNUAL7D, maxAnnual7D);
			logger.info("已开户用户主页初期化成功 resultMap = " + resultMap);
			return JSONObject.fromObject(resultMap).toString();
		
		}catch(Exception e){
			e.printStackTrace();
			logger.error("已开户用户主页初期化失败", e);
			resultMap.put(CommonConsts.RETCODE, RetCode.FAIL);
			resultMap.put(CommonConsts.RETMSG, "已开户用户主页初期化失败");
			return JSONObject.fromObject(resultMap).toString();
		}
	}
	
	/**
	 * 设置总资产显示隐藏
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/setAmtDisStatus",produces="text/html;charset=UTF-8")
	@ResponseBody
	public String setAmtDisStatus(HttpServletRequest request, HttpServletResponse response){
		logger.info("【设置总资产显示隐藏】开始");
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try{
			//总资产显示状态
			String amtDisStatus = request.getParameter(CommonConsts.AMTDISSTATUS);
			
			//获取登录人的商户编号
			String merId = "";
			if(request.getSession().getAttribute(CommonConsts.MERID) != null){
				merId = request.getSession().getAttribute(CommonConsts.MERID).toString();
			}
			
			//设置总资产显示状态
			String redisKey = CacheConsts.AMTDISSTATUS.replace(CommonConsts.MERID, merId);
			logger.info("设置缓存 redisKey = " + redisKey + ";amtDisStatus=" + amtDisStatus);
			RedisUtil.set(redisKey, PropertyConsts.THREEMONTH, amtDisStatus);
			resultMap.put(CommonConsts.RETCODE, RetCode.SUCCESS);
			resultMap.put(CommonConsts.RETMSG, "设置总资产显示隐藏成功");
			return JSONObject.fromObject(resultMap).toString();
		}catch(Exception e){
			e.printStackTrace();
			logger.error("设置总资产显示隐藏失败", e);
			resultMap.put(CommonConsts.RETCODE, RetCode.FAIL);
			resultMap.put(CommonConsts.RETMSG, "设置总资产显示隐藏失败");
			return JSONObject.fromObject(resultMap).toString();
		}
	}
	
	/**
	 * 最近N个月份列表
	 * 
	 * @param request
	 * @param response 
	 * @return
	 */
	@RequestMapping(value="/getYearMonths",produces="text/html;charset=UTF-8")
	@ResponseBody
	public String getYearMonths(HttpServletRequest request, HttpServletResponse response){
	
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try{
			//月份数
			Integer months = Integer.parseInt(request.getParameter(CommonConsts.MONTHS));
			List<String> yearMonthList = new ArrayList<String>(); 
			//获取当前时间
			Calendar calendar = Calendar.getInstance();
			yearMonthList.add(DateTimesUtil.dateYm7(calendar.getTime()));
			for(int i = 1; i < months; i++){
				calendar.add(Calendar.MONTH, -1);
				yearMonthList.add(DateTimesUtil.dateYm7(calendar.getTime()));
			}
			
			resultMap.put(CommonConsts.RETCODE, RetCode.SUCCESS);
			resultMap.put(CommonConsts.RETMSG, "获取年份列表成功");
			resultMap.put(CommonConsts.RESULTLIST, yearMonthList);
			logger.info("获取年份列表成功 resultMap = " + resultMap);
			return JSONObject.fromObject(resultMap).toString();
			
		}catch(Exception e){
			e.printStackTrace();
			logger.error("获取年份列表失败", e);
			resultMap.put(CommonConsts.RETCODE, RetCode.FAIL);
			resultMap.put(CommonConsts.RETMSG, "获取年份列表失败");
			return JSONObject.fromObject(resultMap).toString();
		}
	}
	
	/**
	 * 订单查询
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/getFundTradeList",produces="text/html;charset=UTF-8")
	@ResponseBody
	public String getFundTradeList(HttpServletRequest request, HttpServletResponse response){
		logger.info("【订单查询】开始");
		Map<String, Object> resultMap = new HashMap<String, Object>();
		
		try{
			//申购赎回标识
			String divisionFlag = request.getParameter(CommonConsts.DIVISIONFLAG);
			//产品类型
			String fundNo = request.getParameter(CommonConsts.FUNDNO);
			//年月份
			String yearMonth = request.getParameter(CommonConsts.YEAR_MONTH);
			 
			//获取登录人的商户编号
			String merId = "";
			if(request.getSession().getAttribute(CommonConsts.MERID) != null){
				merId = request.getSession().getAttribute(CommonConsts.MERID).toString();
			}
			
			Calendar calendar = Calendar.getInstance();
			calendar.set(Calendar.YEAR, Integer.parseInt(yearMonth.substring(0, 4)));
			calendar.set(Calendar.MONTH, Integer.parseInt(yearMonth.substring(4, 6))-1);
			//结束日期
			calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
			String endDate = DateTimesUtil.date8(calendar.getTime());
			//开始日期
			calendar.set(Calendar.DAY_OF_MONTH, 1);
			String startDate = DateTimesUtil.date8(calendar.getTime());
			
			//基金交易查询（SAAS）S01001（个人、企业）
			Map<String, Object> paramMap = new HashMap<String, Object>();
			ReqMessage reqMessage = ReqMessageUtil.makeFundReq();
			//流水号
			paramMap.put(CommonConsts.RPID, reqMessage.getRpid());
			//日期
			paramMap.put(CommonConsts.REQDATE, reqMessage.getReqDate());
			//时间
			paramMap.put(CommonConsts.REQTIME, reqMessage.getReqTime());
			//版本号
			paramMap.put(CommonConsts.VERSION, "1.0");
			//商户编号
			paramMap.put(CommonConsts.USERMERID, merId);
			//商户用户编号
			paramMap.put(CommonConsts.MERUSERID, merId);
			//内部来源商户号(EC030004:saas个体户)
			paramMap.put(CommonConsts.SOURCECHANNEL, PropertyConsts.SOURCECHANNEL_EC030004);
			//基金渠道编码(PropertyConsts.FUNDMERID:天天基金公司渠道)
			paramMap.put(CommonConsts.FUNDCHANNELCODE, PropertyConsts.FUNDMERID);
			//基金编号
			paramMap.put(CommonConsts.FUNDNO, fundNo);
			//开始时间
			paramMap.put(CommonConsts.START_DATE, startDate);
			//结束时间
			paramMap.put(CommonConsts.END_DATE, endDate);
			//申购、赎回标识
			paramMap.put(CommonConsts.DIVISIONFLAG, divisionFlag);
			logger.info("【基金交易查询（SAAS）S01001（个人、企业）】访问路径："+ PropertyConsts.FPBG_S01001 + " 输入参数：" + paramMap);
			Map<String, Object> tradeMap = HttpUtil.httpPostForm2Xml(PropertyConsts.FPBG_S01001, paramMap);
			logger.info("【基金交易查询（SAAS）S01001（个人、企业）】输出参数：" + tradeMap);
			if(!tradeMap.get(CommonConsts.RETCODE).equals(RetCode.SUCCESS)){
				logger.info("【基金交易查询（SAAS）S01001（个人、企业）】查询失败");
				resultMap.put(CommonConsts.RETCODE, RetCode.FAIL);
				resultMap.put(CommonConsts.RETMSG, "获取订单列表失败");
				return JSONObject.fromObject(resultMap).toString();
			}
			
			List<Map<String, String>> resultList = new ArrayList<Map<String, String>>();
			//交易列表 
			String fundTradeListStr = (String) tradeMap.get(CommonConsts.FUNDTRADELIST);
			List<Map<String, String>> fundTradeList = new Gson().fromJson(fundTradeListStr, new TypeToken<List<Map<String, String>>>(){}.getType());
			
			if(fundTradeList != null && fundTradeList.size() > 0){
				fundTradeList = SortUtil.sortListDesc(fundTradeList, CommonConsts.ORDERDATE);
				for(int i = 0; i < fundTradeList.size(); i++){
					Map<String, String> detailMap = fundTradeList.get(i);
					Map<String, String> dataMap = new HashMap<String, String>();
					//订单号
					dataMap.put(CommonConsts.ORDERID, detailMap.get(CommonConsts.ORDERID));
					//份额（分转元）
					dataMap.put(CommonConsts.AMOUNTY, AmountUtil.Cent2Dollar(detailMap.get(CommonConsts.AMOUNT).toString()));
					//业务类型
					dataMap.put(CommonConsts.SERVTYPE, detailMap.get(CommonConsts.SERVTYPE));
					//订单日期(yyyy-MM-dd)
					dataMap.put(CommonConsts.ORDERDATE, DateTimesUtil.date10(detailMap.get(CommonConsts.ORDERDATE).toString()));
					resultList.add(dataMap);
				}
			} 
			
			resultMap.put(CommonConsts.RETCODE, RetCode.SUCCESS);
			resultMap.put(CommonConsts.RETMSG, "获取订单列表成功");
			resultMap.put(CommonConsts.RESULTLIST, resultList);
			logger.info("获取订单列表成功 resultMap = " + resultMap);
			return JSONObject.fromObject(resultMap).toString();
			
		}catch(Exception e){
			e.printStackTrace();
			logger.error("获取订单列表失败", e);
			resultMap.put(CommonConsts.RETCODE, RetCode.FAIL);
			resultMap.put(CommonConsts.RETMSG, "获取订单列表失败");
			return JSONObject.fromObject(resultMap).toString();
		}
	}
	
	/**
	 * 收益查询
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/getIncomeDetailList",produces="text/html;charset=UTF-8")
	@ResponseBody
	public String getIncomeDetailList(HttpServletRequest request, HttpServletResponse response){
		logger.info("【收益查询】开始");
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try{
			//年月份
			String yearMonth = request.getParameter(CommonConsts.YEAR_MONTH);
			//获取登录人的商户编号
			String merId = "";
			if(request.getSession().getAttribute(CommonConsts.MERID) != null){
				merId = request.getSession().getAttribute(CommonConsts.MERID).toString();
			}
			
			//当前时间
			Calendar calendar = Calendar.getInstance();
			//当前年月
			String currentYm = DateTimesUtil.dateYm6(calendar.getTime());
			calendar.set(Calendar.YEAR, Integer.parseInt(yearMonth.substring(0, 4)));
			calendar.set(Calendar.MONTH, Integer.parseInt(yearMonth.substring(4, 6))-1);
			//开始日期（月第一天）
			calendar.set(Calendar.DAY_OF_MONTH, 1);
			String startDate = DateTimesUtil.date8(calendar.getTime());
			//结束日期（月最后一天）
			calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
			String endDate = DateTimesUtil.date8(calendar.getTime());
			
			//缓存收益列表KEY
			String incomeDetailKey = CacheConsts.INCOMEDETAIL.replace(CommonConsts.MERID, merId).replace(DateTimesUtil.formatDay6Str, yearMonth);
			//非当前月
			if(!yearMonth.substring(0, 6).equals(currentYm)){
				//缓存中获取收益列表
				String redisResultMap = RedisUtil.get(incomeDetailKey);
				if(!StringUtil.isEmpty(redisResultMap)){
					logger.info("获取收益列表成功 resultMap = " + redisResultMap);
					return JSONObject.fromObject(redisResultMap).toString();
				}
			}
			
			//用户每日收益列表查询	/fpbg/S01005
			Map<String, Object> paramMap = new HashMap<String, Object>();
			ReqMessage reqMessage = ReqMessageUtil.makeFundReq();
			//流水号
			paramMap.put(CommonConsts.RPID, reqMessage.getRpid());
			//日期
			paramMap.put(CommonConsts.REQDATE, reqMessage.getReqDate());
			//时间
			paramMap.put(CommonConsts.REQTIME, reqMessage.getReqTime());
			//版本号
			paramMap.put(CommonConsts.VERSION, "1.0");
			//商户编号
			paramMap.put(CommonConsts.USERMERID, merId);
			//商户用户编号
			paramMap.put(CommonConsts.MERUSERID, merId);
			//内部来源商户号（EC030004：saas个体户）
			paramMap.put(CommonConsts.SOURCECHANNEL, PropertyConsts.SOURCECHANNEL_EC030004);
			//基金渠道编码
			paramMap.put(CommonConsts.FUNDCHANNELCODE, PropertyConsts.FUNDMERID);
			//基金编号
			paramMap.put(CommonConsts.FUNDNO, PropertyConsts.FUNDNO);
			//开始时间
			paramMap.put(CommonConsts.START_DATE, startDate);
			//结束时间
			paramMap.put(CommonConsts.END_DATE, endDate);
		
			logger.info("【用户每日收益列表查询】访问路径："+ PropertyConsts.FPBG_S01005 + " 输入参数：" + paramMap);	
			Map<String, Object> inComeMap = HttpUtil.httpPostForm2Xml(PropertyConsts.FPBG_S01005, paramMap);
			logger.info("【用户每日收益列表查询】输出参数：" + inComeMap);
			if(!inComeMap.get(CommonConsts.RETCODE).equals(RetCode.SUCCESS)){
				logger.info("【用户每日收益列表查询】查询失败");
				resultMap.put(CommonConsts.RETCODE, RetCode.FAIL);
				resultMap.put(CommonConsts.RETMSG, "获取订单列表失败");
				return JSONObject.fromObject(resultMap).toString();
			}
			
			List<Map<String, String>> resultList = new ArrayList<Map<String, String>>();
			//总累计收益
			BigDecimal totalProFitVal = new BigDecimal("0");
			if(inComeMap.get(CommonConsts.FUNDINCOME) != null){
				String incomeDetailListStr = (String) inComeMap.get(CommonConsts.FUNDINCOME);
				List<Map<String, String>> incomeDetailList = new Gson().fromJson(incomeDetailListStr, new TypeToken<List<Map<String, String>>>(){}.getType());
				if(incomeDetailList != null && incomeDetailList.size() > 0){
					incomeDetailList = SortUtil.sortListDesc(incomeDetailList, CommonConsts.PROFITDATE);
					for(Map<String, String> incomeDetailMap : incomeDetailList){
						Map<String, String> dataMap = new HashMap<String, String>();
						//收益日期(yyyy-MM-dd)
						dataMap.put(CommonConsts.PROFITDATE, DateTimesUtil.date10(incomeDetailMap.get(CommonConsts.PROFITDATE).toString()));
						//收益金额(分转元)
						String lastDayProFit = incomeDetailMap.get(CommonConsts.LASTDAY_PROFIT).toString();
						dataMap.put(CommonConsts.LASTDAY_PROFIT, AmountUtil.Cent2Dollar(lastDayProFit));
						resultList.add(dataMap);
						//累计收益
						totalProFitVal = totalProFitVal.add(new BigDecimal(lastDayProFit));
					}
				}
			}
			
			resultMap.put(CommonConsts.RETCODE, RetCode.SUCCESS);
			resultMap.put(CommonConsts.RETMSG, "获取收益列表成功");
			//收益列表
			resultMap.put(CommonConsts.RESULTLIST, resultList);
			//总累计收益（分转元）
			resultMap.put("totalAmt", AmountUtil.Cent2Dollar(totalProFitVal.toString()));
			logger.info("获取收益列表成功 resultMap=" + resultMap);
			//存缓存
			String resultStr = JSONObject.fromObject(resultMap).toString();
			RedisUtil.set(incomeDetailKey, ValueConsts.ONE_WEEK, resultStr);
			return resultStr;
		}catch(Exception e){
			e.printStackTrace();
			logger.error("获取收益列表失败", e);
			resultMap.put(CommonConsts.RETCODE, RetCode.FAIL);
			resultMap.put(CommonConsts.RETMSG, "获取收益列表失败");
			return JSONObject.fromObject(resultMap).toString();
		}
	}
	
	/**
	 * 转出初期化接口
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/initRedeem",produces="text/html;charset=UTF-8")
	@ResponseBody
	public String initRedeem(HttpServletRequest request, HttpServletResponse response){
		logger.info("【转出初期化】开始");
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try{
			//获取登录人的商户编号
			String merId = "";
			if(request.getSession().getAttribute(CommonConsts.MERID) != null){
				merId = request.getSession().getAttribute(CommonConsts.MERID).toString();
			}
			
			//基金累积收益（业务线）
			Map<String, Object> paramMap = new HashMap<String, Object>();
			ReqMessage reqMessage = ReqMessageUtil.makeFundReq();
			//流水号
			paramMap.put(CommonConsts.RPID, reqMessage.getRpid());
			//日期
			paramMap.put(CommonConsts.REQDATE, reqMessage.getReqDate());
			//时间
			paramMap.put(CommonConsts.REQTIME, reqMessage.getReqTime());
			//版本号
			paramMap.put(CommonConsts.VERSION, "1.0");
			//商户编号
			paramMap.put(CommonConsts.MERID, PropertyConsts.FUNDMERID);
			//用户所属的商户号
			paramMap.put(CommonConsts.USERMERID, merId);
			//用户编号
			paramMap.put(CommonConsts.USERID, merId);
			//基金编号
			paramMap.put(CommonConsts.FUNDNO, PropertyConsts.FUNDNO);
			//基金业务产品号
			paramMap.put(CommonConsts.BPRODUCTID, PropertyConsts.BPRODUCTID);
			logger.info("【基金累积收益（业务线）】访问路径："+ PropertyConsts.ESOOPAY_J06001 + " 输入参数：" + paramMap);	
			Map<String, Object> balanceMap = HttpUtil.httpPostForm2Xml(PropertyConsts.ESOOPAY_J06001, paramMap);
			logger.info("【基金累积收益（业务线）】输出参数：" + balanceMap);
			if(!balanceMap.get(CommonConsts.RETCODE).equals(RetCode.SUCCESS)){
				logger.info("【基金累积收益（业务线）】查询失败");
				resultMap.put(CommonConsts.RETCODE, RetCode.FAIL);
				resultMap.put(CommonConsts.RETMSG, "转出初期化失败");
				return JSONObject.fromObject(resultMap).toString();
			}
			
			//基金最低认购查询（业务线）
			Map<String, Object> paramMinMap = new HashMap<String, Object>();
			//流水号
			paramMinMap.put(CommonConsts.RPID, ReqMessageUtil.makeFundReq().getRpid());
			//基金编号
			paramMinMap.put(CommonConsts.FUNDNO, PropertyConsts.FUNDNO);
			logger.info("【基金最低认购查询（业务线）】访问路径："+ PropertyConsts.FPBG_S01002 + " 输入参数：" + paramMap);	
			Map<String, Object> minAmtMap = HttpUtil.httpPostForm2Xml(PropertyConsts.FPBG_S01002, paramMap);
			logger.info("【基金最低认购查询（业务线）】输出参数：" + minAmtMap);
			if(!minAmtMap.get(CommonConsts.RETCODE).equals(RetCode.SUCCESS)){
				logger.info("【基金最低认购查询（业务线）】查询失败");
				resultMap.put(CommonConsts.RETCODE, RetCode.FAIL);
				resultMap.put(CommonConsts.RETMSG, "转出初期化失败");
				return JSONObject.fromObject(resultMap).toString();
			}
			
			//基金交易查询（SAAS）S01001（个人、企业）
			String currentDate = DateTimesUtil.date8();
			Map<String, Object> tradeParamMap = new HashMap<String, Object>();
			//流水号
			tradeParamMap.put(CommonConsts.RPID, reqMessage.getRpid());
			//日期
			tradeParamMap.put(CommonConsts.REQDATE, reqMessage.getReqDate());
			//时间
			tradeParamMap.put(CommonConsts.REQTIME, reqMessage.getReqTime());
			//版本号
			tradeParamMap.put(CommonConsts.VERSION, "1.0");
			//商户编号
			tradeParamMap.put(CommonConsts.USERMERID, merId);
			//商户用户编号
			tradeParamMap.put(CommonConsts.MERUSERID, merId);
			//内部来源商户号(EC030004:saas个体户)
			tradeParamMap.put(CommonConsts.SOURCECHANNEL, PropertyConsts.SOURCECHANNEL_EC030004);
			//基金渠道编码(PropertyConsts.FUNDMERID:天天基金公司渠道)
			tradeParamMap.put(CommonConsts.FUNDCHANNELCODE, PropertyConsts.FUNDMERID);
			//基金编号
			tradeParamMap.put(CommonConsts.FUNDNO, PropertyConsts.FUNDNO);
			//开始时间
			tradeParamMap.put(CommonConsts.START_DATE, currentDate);
			//结束时间
			tradeParamMap.put(CommonConsts.END_DATE, currentDate);
			//申购、赎回标识（赎回）
			tradeParamMap.put(CommonConsts.DIVISIONFLAG, CommonConsts.REDEMPTION);
			logger.info("【基金交易查询（SAAS）S01001（个人、企业）】访问路径："+ PropertyConsts.FPBG_S01001 + " 输入参数：" + tradeParamMap);
			Map<String, Object> tradeMap = HttpUtil.httpPostForm2Xml(PropertyConsts.FPBG_S01001, tradeParamMap);
			logger.info("【基金交易查询（SAAS）S01001（个人、企业）】输出参数：" + tradeMap);
			if(!tradeMap.get(CommonConsts.RETCODE).equals(RetCode.SUCCESS)){
				logger.info("【基金交易查询（SAAS）S01001（个人、企业）】查询失败");
				resultMap.put(CommonConsts.RETCODE, RetCode.FAIL);
				resultMap.put(CommonConsts.RETMSG, "获取订单列表失败");
				return JSONObject.fromObject(resultMap).toString();
			}
			
			//交易列表
			String fundTradeListStr = (String) tradeMap.get(CommonConsts.FUNDTRADELIST);
			List<Map<String, String>> fundTradeList = new Gson().fromJson(fundTradeListStr, new TypeToken<List<Map<String, String>>>(){}.getType());
			//今天累计购买金额
			BigDecimal totalAmt = new BigDecimal("0");
			if(fundTradeList != null && fundTradeList.size() > 0){
				for(int i = 0; i < fundTradeList.size(); i++){
					//赎回失败状态：2、5
					if(!"2".equals(fundTradeList.get(i).get(CommonConsts.ORDERSTATE)) 
							&& !"5".equals(fundTradeList.get(i).get(CommonConsts.ORDERSTATE)) ){
						totalAmt = totalAmt.add(new BigDecimal(fundTradeList.get(i).get(CommonConsts.AMOUNT).toString()));
					}
				}
			} 
			logger.info("今天累计赎回金额（分）： totalAmt=" + totalAmt);
			
			//日最大赎回金额(分)-今天累计购买金额(分)
			BigDecimal maxRedeemAmt = new BigDecimal(PropertyConsts.DAYMAXREDEEMAMT).subtract((totalAmt));
			
			//店铺部署详情查询
			com.umpay.sp.model.common.ReqMessage reqMess = ReqMessageUtil.makeSpReq();
			reqMess.put(XmlData.STORE_ID, merId);
			logger.info("【店铺部署详情查询】输入参数： reqMess=" + reqMess);
			com.umpay.sp.model.common.ResMessage resMessage = storeInfServiceRemote.getStoreInfByPri(reqMess);
			logger.info("【店铺部署详情查询】输出参数： resMessage=" + resMessage);
			StoreInf storeInf = (StoreInf)resMessage.getValue(XmlData.STORE_INF);
			if(!resMessage.getRetCode().equals(RetCode.SUCCESS) || storeInf == null){
				logger.info("店铺部署详情查询失败！");
		    	resultMap.put("retCode", RetCode.FAIL);
				resultMap.put("retMsg", "店铺部署详情查询失败");
				return JSONObject.fromObject(resultMap).toString();
			}
			//预留手机号
			String prestorePhone = "";
			if(StringUtil.isEmpty(storeInf.getPrestorePhone())){
				prestorePhone = storeInf.getPayeeMobileId();
			}else{
				prestorePhone = storeInf.getPrestorePhone();
			}
			
			resultMap.put(CommonConsts.RETCODE, RetCode.SUCCESS);
			resultMap.put(CommonConsts.RETMSG, "转出初期化成功");
			//预留手机号
			resultMap.put(CommonConsts.MOBILEID, prestorePhone);
			//可用余额(分转元) 
			String balance = "0.00";
			if(balanceMap.get(CommonConsts.BALANCE) != null){
				balance = AmountUtil.Cent2Dollar(balanceMap.get(CommonConsts.BALANCE).toString());
			}
			resultMap.put(CommonConsts.BALANCE, balance);
			//最小赎回金额(分转元) 
			String minRedeemAmount = "0.00";
			if(minAmtMap.get(CommonConsts.MINREDEEMAMOUNT) != null){
				minRedeemAmount = AmountUtil.Cent2Dollar(minAmtMap.get(CommonConsts.MINREDEEMAMOUNT).toString());
			}
			resultMap.put(CommonConsts.MINREDEEMAMOUNT, minRedeemAmount);
			//最大赎回金额(分转元) 
			resultMap.put(CommonConsts.MAXREDEEMAMT, AmountUtil.Cent2Dollar(maxRedeemAmt.toString()));
			logger.info("转出初期化成功 resultMap=" + resultMap);
			return JSONObject.fromObject(resultMap).toString();
		}catch(Exception e){
			e.printStackTrace();
			logger.error("转出初期化失败", e);
			resultMap.put(CommonConsts.RETCODE, RetCode.FAIL);
			resultMap.put(CommonConsts.RETMSG, "转出初期化失败");
			return JSONObject.fromObject(resultMap).toString();
		}
	}
	
	/**
	 * 转出(赎回)接口
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/userPurchase",produces="text/html;charset=UTF-8")
	@ResponseBody
	public String userPurchase(HttpServletRequest request, HttpServletResponse response){
		logger.info("【用户转出(赎回)】开始");
		Map<String, Object> resultMap = new HashMap<String, Object>();
		try{
			//短信验证码
			String verifyCode = request.getParameter(CommonConsts.VERIFYCODE);
			//是否快速取现标识(1:快速赎回 2:普通赎回)
			String isFast = request.getParameter(CommonConsts.ISFAST);
			//手机号
			String mobileId = request.getParameter(CommonConsts.MOBILEID);
			//赎回金额
			String origAmt = request.getParameter(CommonConsts.ORIGAMT);
			
			//获取流水号
			String smsVerifyTrace = "";
			if(request.getSession().getAttribute(CommonConsts.SMSVERIFYTRACE) != null){
				smsVerifyTrace = request.getSession().getAttribute(CommonConsts.SMSVERIFYTRACE).toString();
			}
			//获取登录人的商户编号
			String merId = "";
			if(request.getSession().getAttribute(CommonConsts.MERID) != null){
				merId = request.getSession().getAttribute(CommonConsts.MERID).toString();
			}
			
			//校验短信验证码
			logger.info("【校验短信验证码】输入参数：" + "mobileId:" + mobileId + "smsVerifyTrace:" + smsVerifyTrace + "verifyCode:" + verifyCode);
			Map<String,String> resMsg = SmsCheckUtil.checksms(mobileId, smsVerifyTrace, verifyCode);
			logger.info("【校验短信验证码】输出参数：" + resMsg);
			if(!resMsg.get(CommonConsts.RETCODE).equals(RetCode.SUCCESS)){
				logger.info("【校验短信验证码）】失败");
				resultMap.put(CommonConsts.RETCODE, RetCode.REQPARAM_ERR);
				resultMap.put(CommonConsts.RETMSG, "校验短信验证码错误");
				return JSONObject.fromObject(resultMap).toString();
			}
			
			//查询绑定银行卡信息
			com.umpay.operation.common.ReqMessage reqM = ReqMessageUtil.makeOpReq();
			Map<String, Object> reqMap = new HashMap<String, Object>();
			reqMap.put(CommonConsts.MERID, merId);
		    reqMap.put(CommonConsts.DELAYDAYS, ValueConsts.EDRAW_DELAYDAYS);
		    reqMap.put(CommonConsts.STATE, ValueConsts.EDRAW_STATE);
		    reqMap.put(CommonConsts.RECVBANKACCPRO, ValueConsts.EDRAW_RECVBANKACCPRO);
		    reqM.setReqMap(reqMap);
			logger.info("【查询商户绑定银行卡信息接口】输入参数：" + reqM);
			com.umpay.operation.common.ResMessage resMessage = edrawInfServiceRemote.queryEdrewInf(reqM);
			logger.info("【查询商户绑定银行卡信息接口】输出参数：" + resMessage);
			EdrawInf edrawInf = (EdrawInf)resMessage.getResMap().get(CommonConsts.EDRAWINF);
			if(!resMessage.getRetCode().equals(RetCode.SUCCESS) || edrawInf == null){
				logger.info("调用查询商户绑卡信息接口失败!");
				return ResultJsonUtil.resultJson(RetCode.FAIL, MsgConsts.E00433058);
			} 
			
			//单笔赎回到银行卡BE354102（企业）
			String resultStr = postPurchase(merId, origAmt, isFast, edrawInf);
			if(StringUtil.isNotEmpty(resultStr)){
				return resultStr;
			}
			
			//计算到账时间(yyyy-MM-dd HH:mm | yyyy-MM-dd 17:00-19:00)
			String tradeTime = calTradeTime(isFast);
			
			//转出申请时间 (yyyy-MM-dd HH:mm)
			String applicationTime = DateTimesUtil.datetime15(Calendar.getInstance().getTime());
			
			//转出申请时间
			resultMap.put(CommonConsts.APPLICATIONTIME, applicationTime);
			//到账时间
			resultMap.put(CommonConsts.TRADETIME, tradeTime);
			resultMap.put(CommonConsts.RETCODE, RetCode.SUCCESS);
			resultMap.put(CommonConsts.RETMSG, "转出成功");
			logger.info("转出成功 resultMap=" + resultMap);
			return JSONObject.fromObject(resultMap).toString();
		}catch(Exception e){
			e.printStackTrace();
			logger.info("转出失败" + e);
			resultMap.put(CommonConsts.RETCODE, RetCode.FAIL);
			resultMap.put(CommonConsts.RETMSG, "转出失败");
			return JSONObject.fromObject(resultMap).toString();
		}
	}
	
	/**
	 * 单笔赎回到银行卡BE354102（企业）
	 * 
	 * @param merId 商户号
	 * @param origAmt 赎回金额
	 * @param isFast 是否快速取现标识
	 * @param edrawInf 银行卡信息
	 * @return
	 */
	private String postPurchase(String merId, String origAmt, String isFast, EdrawInf edrawInf) throws Exception {
		//单笔赎回到银行卡BE354102（企业）
		Map<String, Object> paramMap = new HashMap<String, Object>();
		ReqMessage reqMessage = ReqMessageUtil.makeFundReq();
		//流水号
		paramMap.put(CommonConsts.RPID, reqMessage.getRpid());
		//日期
		paramMap.put(CommonConsts.REQDATE, reqMessage.getReqDate());
		//时间
		paramMap.put(CommonConsts.REQTIME, reqMessage.getReqTime());
		//用户所属的商户号
		paramMap.put(CommonConsts.MERID, merId);
		//订单号
		paramMap.put(CommonConsts.ORDERID, OrderIdUtil.getSmOrderId(merId));
		//订单日期
		paramMap.put(CommonConsts.ORDERDATE, reqMessage.getReqDate());
		//赎回订单金额（元转分）
		paramMap.put(CommonConsts.ORIGAMT, AmountUtil.DollarToCent(origAmt));
		//收款方账号
		paramMap.put(CommonConsts.INMEDIAID, edrawInf.getBankAccount());
		//收款方户名
		paramMap.put(CommonConsts.INACCOUNTNAME, edrawInf.getColAccName());
		//收款方账户的发卡行
		paramMap.put(CommonConsts.BINBANKID, edrawInf.getBinBankId());
		//开户行支行全称
		paramMap.put(CommonConsts.BANKBRHNAME, edrawInf.getBankName());
		//收款方账户属性(0对私 1对公)
		if(0 == edrawInf.getRecvBankAccPro()){
			//对公对私标识(0-对私)
			paramMap.put(CommonConsts.ACCPRO, "0");
			//是否需要审核(0-不需要审核)
			paramMap.put(CommonConsts.CHECKFLAG, "0");
		}else{
			//省
			paramMap.put(CommonConsts.PROVNAME, edrawInf.getColAccProv());
			//市
			paramMap.put(CommonConsts.CITYNAME, edrawInf.getColAccArea());
			//摘要
			paramMap.put(CommonConsts.PURPOSE, edrawInf.getPurPose());
			//对公对私标识(1-对公)
			paramMap.put(CommonConsts.ACCPRO, "1");
			//是否需要审核(1-需要审核)
			paramMap.put(CommonConsts.CHECKFLAG, "1");
		}
		//手续费类型(1-	手续费从现金账户扣除)
		paramMap.put(CommonConsts.COMAMTTYPE, "1");
		//手续费承担方id(1-交易方承担手续费)
		paramMap.put(CommonConsts.SETCOMTYPE, "1");
		//手续费扣款方式(2-内扣)
		paramMap.put(CommonConsts.CUTFEETYPE, "2");
		//基金编号
		paramMap.put(CommonConsts.FUNDNO, PropertyConsts.FUNDNO);
		//基金名称
		paramMap.put(CommonConsts.FUNDNAME, PropertyConsts.FUNDNAME);
		//是否快速取现标识
		paramMap.put(CommonConsts.ISFAST, isFast);
		//基金公司商户号
		paramMap.put(CommonConsts.FUNDMERID, PropertyConsts.FUNDMERID);
		
		logger.info("【单笔赎回到银行卡BE354102（企业）接口】访问路径："+ PropertyConsts.ESOOPAY_BE354102 + " 输入参数：" + paramMap);	
		Map<String, Object> bankMap = HttpUtil.httpPostForm2Xml(PropertyConsts.ESOOPAY_BE354102, paramMap);
		logger.info("【单笔赎回到银行卡BE354102（企业）接口】输出参数：" + bankMap);
		if(!bankMap.get(CommonConsts.RETCODE).equals(RetCode.SUCCESS)){
			logger.info("【单笔赎回到银行卡BE354102（企业）接口】转出失败");
			Map<String, Object> resultMap = new HashMap<String, Object>();
			resultMap.put(CommonConsts.RETCODE, RetCode.FAIL);
			resultMap.put(CommonConsts.RETMSG, "转出失败");
			return JSONObject.fromObject(resultMap).toString();
		}
		
		return null;
	}
	
	/**
	 * 计算到账时间 
	 * 
	 * @param isFast 是否快速取现标识
	 * @return
	 */
	private String calTradeTime(String isFast){
		Calendar calendar = Calendar.getInstance();
		//到账时间
		String tradeTime = "";
		//快速赎回
		if(Integer.parseInt(isFast) == 1){
			//到账时间=当前时间+30分钟
			calendar.add(Calendar.MINUTE, 30);
			//到账时间(yyyy-MM-dd HH:mm)
			tradeTime = DateTimesUtil.datetime15(calendar.getTime());
		
		//普通赎回
		}else if(Integer.parseInt(isFast) == 2){
			if(calendar.getTime().getHours() >= 15){
				//到账时间=当前时间+2天
				calendar.add(Calendar.DATE, 2);
				tradeTime = DateTimesUtil.date10(calendar.getTime());
			}else{
				//到账时间=当前时间+1天
				calendar.add(Calendar.DATE, 1);
				tradeTime = DateTimesUtil.date10(calendar.getTime());
			}
			int weekDay = calendar.get(Calendar.DAY_OF_WEEK);
			if(weekDay == 1 || weekDay == 7){
				//到账时间=到账时间+2天
				calendar.add(Calendar.DATE, 2);
				tradeTime = DateTimesUtil.date10(calendar.getTime());
			}
			//到账时间(yyyy-MM-dd 17:00-19:00)
			tradeTime = tradeTime + CommonConsts.TRADEENDTIME;
		}
		
		return tradeTime;
	}
	
	/**
	 * 清缓存
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value="/clearRedisByKey",produces="text/html;charset=UTF-8")
	@ResponseBody
	public void clearRedisByKey(HttpServletRequest request, HttpServletResponse response){
		String redisKey = request.getParameter("key");
		if(StringUtil.isNotEmpty(redisKey)){
			//清缓存
			RedisUtil.del(redisKey);
		}
	}
	
}